<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<title></title>
		<style type="text/css">
			#mybooks{
				border: 10px groove red;
				width: 70%;
			}
		</style>
		<script>
			function showBook(v)
			{
				var p=document.getElementById("book");
				if(v.value=="dog")
				{
					//p.src="";
					p.setAttribute("src","images/dd_logo.jpg");
				}else{
					p.setAttribute("src","../day6/icon-4.jpg");
				}
			}
			function addImg()
			{
				var mybooks=document.getElementById("mybooks");
				//mybooks.innerHTML+="<img src=''/>";
				var im=document.createElement("img");
				im.setAttribute("src","images/dog.jpg");
				im.setAttribute("width","100px");
				im.setAttribute("height","200px");
				mybooks.appendChild(im);//加到div后面
				//document.body.appendChild(im);
			}
			function delImg()
			{
				var mybooks=document.getElementById("mybooks");
				var last=mybooks.children[mybooks.children.length-1];
				mybooks.removeChild(last);
				//document.body.removeChild(last);
			}
		</script>
	</head>
	<body>
		<input type="radio" name="book" onclick="showBook(this)" value="dog"/>我和我的狗
		<input type="radio" name="book" onclick="showBook(this)" value="frog"/>雾霾来了，怎么班
	 	<br />
	 	<img alt="没有选择" id="book" />
	 	<input type="button" value="增加一个图片" onclick="addImg()"/>
	 	<input type="button" value="删除最后一张图片" onclick="delImg()"/>
	 	<div id="mybooks"></div>
	</body>
</html>
